<template>
  <el-dialog :visible.sync="visibleAudit" title="审核" append-to-body width="20%">
    <el-radio-group v-model="radio">
    <el-radio :label="0">通过</el-radio>
    <el-radio :label="1">驳回</el-radio>
  </el-radio-group>
  <!-- 确认按钮 -->
            <div class="confirm-btn">
              <button @click="confirm(1)">确认</button>
            </div>


            <!-- 驳回 -->
             <el-dialog @close="close(2)" :visible.sync="visibleReject" title="审核意见" append-to-body width="25%">
              <el-input
  type="textarea"
  :rows="4"
  :clearable="true"
  resize="none"
  placeholder="请输入内容"
  v-model="textarea">
</el-input>

<!-- 确认按钮 -->
            <div class="confirm-btn">
              <button @click="confirm(2)">确认</button>
            </div>
             </el-dialog>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visibleAudit: false,
      visibleReject: false,
      radio: 0,
      textarea: '',
      item: {}
    }
  },
  methods: {
    open(item) {
      this.item = item
      this.visibleAudit = true
    },
    confirm(index) {
      if(index == 1) {
        if(this.radio == 0) {
          this.$emit("changeAuditState", {flag: true, ...this.item}) // 改变审核状态
        } else if(this.radio == 1) {
          this.visibleReject = true
        }
        this.visibleAudit = false
      } else if(index == 2) {
        this.$emit("changeAuditState", {flag: false, auditDesc: this.textarea, ...this.item}) // 改变审核状态
        this.visibleReject = false
      }
      
    },
    close(index) {
      if(index == 1) {

      } else if(index == 2) {
        this.textarea = ''
      }
    }
  }
}
</script>

<style scoped>
.confirm-btn {
  text-align: right;
  margin-top: 10px;
}
.confirm-btn button {
  padding: 6px 16px;
  background: #409eff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
</style>